<?

/**
* local collection functions of tocmenu_45
*
* @author Adesanto Asman
* @version 1.0
* @license Free
* @copyright Copyright (c)2007, Adesanto Asman
* @package CLFetchers
*
*/

/**
* @package CLFetchers
*
*/
class CLFetchers{

  /**
   * fetch nota source detail
   * it is from purchase sub detail
   *
   * @param Database  $Db
   * @param string    $notaSrc
   * @param Composer  $SourceDb
   * @param integer   $nDetail
   * @param array     $lstDetail
   */
  function fetchNotaSrcDetail(&$Db,
                              &$srcWhs,
                              &$notaSrc,
                              &$SourceDb,
                              &$nDetail,
                              &$lstDetail){

    $query	= "SELECT S.*
               FROM ".$SourceDb->fetchValue("srcDbPchHdr")."    H,
                    ".$SourceDb->fetchValue("srcDbPchSubDtl")." S
               WHERE	H.NOTA_SRC='".$notaSrc."'
                      AND S.JOB_ID=H.JOB_ID
                      AND S.WAREHOUSE='".$srcWhs."'
                      AND H.STATUS='"._NOT_ACTIVE."'
               ORDER BY S.NO ASC";

    $Db->execFetchQuery($query,
                        $nDetail,
                        $lstDetail);
  }

  /**
   * list of detail tx
   *
   * @param Database  $Db
   * @param string    $jobId
   * @param Composer  $SourceDb
   * @param integer   $nDetail
   * @param array     $lstDetail
   */
  function fetchLstDataDetail(&$Db,
                              &$jobId,
                              &$SourceDb,
                              &$nDetail,
                              &$lstDetail){

    $query	= "SELECT M.MODEL,
                      D.*
               FROM ".$SourceDb->fetchValue("srcDbModel")." M,
                    ".$SourceDb->fetchValue("srcDbDtl")."   D
               WHERE	D.JOB_ID='".$jobId."'
                      AND D.MODEL_ID=M.MODEL_ID
               ORDER BY D.NO ASC";

    $Db->execFetchQuery($query,
                        $nDetail,
                        $lstDetail);
  }

  /**
   * fetch list of transaction
   *
   * @param Database  $Db
   * @param string    $condt
   * @param string    $srcDb
   * @param integer   $nrows
   * @param array     $result
   */
  function fetchLstTransaction(&$Db,
                                $condt,
                                $srcDb,
                               &$nrows,
                               &$result){

    $query	= "SELECT *
               FROM ".$srcDb."
               ".$condt."
               ORDER BY TR_DATE DESC";

    $Db->execFetchQuery($query,
                        $nrows,
                        $result);
  }
}

?>